<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>柯里化函数的实现</title>
</head>
<body>
    
    <script>

    function add (a,b) {
        return a+b;
    }    
    
    function currying (fn,...rest) {
        let paraAry = rest || [];
        return function () {
            let args = [].slice.call(arguments);
            let all = paraAry.concat(args);
            return fn.apply(this,all);
        }
    }

    var arrCurry = currying(add,1,2);
    console.log(arrCurry());

    var arrCurry1 = currying(add);
    console.log(arrCurry1(1,2));

    /* 以上是简单的柯里化 */


    </script>

</body>
</html>